const path = require('path')
const fileUtil = require('../util/file_util')
module.exports = async (req, res, next) => {
    console.log(req.url);
    const url = req.url;
    let filePath = url.replace('/api', '');
    filePath = `../data${filePath}.json`;
    filePath = path.join(__dirname, filePath);
    console.log(filePath);
    try {
        const ret = await fileUtil.getFileJsonData(filePath)
        res.send(ret)
    } catch (error) {
        next(error)
    }
    await next()
}